﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;

namespace BakalarskaPraca.Generation.Helpers
{
    public static class MatrixHelper
    {
        
        public static Matrix LoadFromString(string text)
        {
           
            text = text.Replace("\n", "");
            text = text.Replace("\t", "");

            string[] parts = text.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);


            if (parts.Count() != 16)
            {
                throw new ArgumentException("Bad matrix input");
            }

            Matrix result = Matrix.Identity;
            result.M11 = float.Parse(parts[0]);
            result.M21 = float.Parse(parts[1]);
            result.M31 = float.Parse(parts[2]);
            result.M41 = float.Parse(parts[3]);
            result.M12 = float.Parse(parts[4]);
            result.M22 = float.Parse(parts[5]);
            result.M32 = float.Parse(parts[6]);
            result.M42 = float.Parse(parts[7]);
            result.M13 = float.Parse(parts[8]);
            result.M23 = float.Parse(parts[9]);
            result.M33 = float.Parse(parts[10]);
            result.M43 = float.Parse(parts[11]);
            result.M14 = float.Parse(parts[12]);
            result.M24 = float.Parse(parts[13]);
            result.M34 = float.Parse(parts[14]);
            result.M44 = float.Parse(parts[15]);
            return result;
        }
    }
}
